<?php

namespace app\api\controller;

use app\admin\model\Bg;
use app\api\model\UserConsumeLog;
use app\common\controller\Api;
use app\common\library\Auth;

/**
 * 分享接口
 */
class Share extends Api
{
    protected $noNeedRight = ['*'];


    //朋友圈短链接
    public function shortlink()
    {
        $ret = $this->auth->getshortlink($this->auth->id);
        if ($ret) {
            $this->success('', $ret);
        } else {
            $this->error($this->auth->getError());
        }
    }

    //海报背景图列表
    public function bgList()
    {
        $list = Bg::order('weigh desc')->select();
        $this->success('',$list);
    }


    //海报
    public function poster()
    {
        $bg_id = input('bg_id',0);

        $qrcode_param[ 'suid' ] = $this->auth->id;

        $app_type = input('app_type ','weapp');
        try {

            $model = new Bg();

            $res = $model->poster($bg_id,$qrcode_param,$app_type);

        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('',$res);
    }
}
